Verbosely say what's happening during doc tests
authorAlex Crichton <alex@alexcrichton.com>
Thu, 7 Aug 2014 15:27:05 +0000 (08:27 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 7 Aug 2014 15:29:38 +0000 (08:29 -0700)
Or at least verbosely say when -v is provided.

src/cargo/ops/cargo_test.rs
tests/test_cargo_test.rs

index 1609e0f6204011aaadc32ff25bf61493a6b9dd53..695bd09c65b9b08f578473e55c2540aa87665c73 100644 (file)
@@ -21,8 +21,14 @@ pub fn run_tests(manifest_path: &Path,
             Some(path) => path,
             None => exe.clone(),
         };
-        try!(options.shell.status("Running", to_display.display()));
-        match compile.process(exe).args(args).exec() {
+        let cmd = compile.process(exe).args(args);
+        try!(options.shell.concise(|shell| {
+            shell.status("Running", to_display.display().to_string())
+        }));
+        try!(options.shell.verbose(|shell| {
+            shell.status("Running", cmd.to_string())
+        }));
+        match cmd.exec() {
             Ok(()) => {}
             Err(e) => return Ok(Some(e))
         }
@@ -58,6 +64,9 @@ pub fn run_tests(manifest_path: &Path,
             }
         }
 
+        try!(options.shell.verbose(|shell| {
+            shell.status("Running", p.to_string())
+        }));
         match p.exec() {
             Ok(()) => {}
             Err(e) => return Ok(Some(e)),
index f1a1c68c2c283c88eb304ec215d555ccb3526644..56e80719425608255a8393029244d44aa2bbd71e 100644 (file)
@@ -46,6 +46,27 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n",
         RUNNING)));
 })
 
+test!(cargo_test_verbose {
+    let p = project("foo")
+        .file("Cargo.toml", basic_bin_manifest("foo").as_slice())
+        .file("src/foo.rs", r#"
+            fn main() {}
+            #[test] fn test_hello() {}
+        "#);
+
+    assert_that(p.cargo_process("cargo-test").arg("-v").arg("hello"),
+        execs().with_stdout(format!("\
+{running} `rustc src[..]foo.rs [..]`
+{compiling} foo v0.5.0 ({url})
+{running} `[..]target[..]test[..]foo-[..] hello`
+
+running 1 test
+test test_hello ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n",
+        compiling = COMPILING, url = p.url(), running = RUNNING)));
+})
+
 test!(many_similar_names {
     let p = project("foo")
         .file("Cargo.toml", r#"